[SUBROUTINE]
version = 1.14
icon = group-offset.png
name = _("Group Offset")
type = group_off
help = _("<b>Offset and/or Rotate a Group of items</b>")
order = act h2 cx cy dr h1 dx dy items

[PARAM_0]
name = _("Items")
type = items
icon = items.png
tool_tip = _("Items to group")

[PARAM_ACT]
name = _("Active")
icon = enable.png
type = bool
value = 1
tool_tip = _("Disabling will disable ALL items")

[PARAM_H2]
name = _("Coords and rotation")
type = sub-header

[PARAM_CX]
name = _("cX")
type = float
icon = center.png
tool_tip = _("Rotation center")
value = 0
metric_value = 0
header = h2

[PARAM_CY]
name = _("cY")
type = float
icon = center.png
tool_tip = _("Rotation center")
value = 0
metric_value = 0
header = h2

[PARAM_H1]
name = _("Items offsets")
type = sub-header

[PARAM_DX]
name = _("dX")
type = float
icon = dx.png
tool_tip = _("X offset")
value = 0.0
header = h1
metric_value = 0.0

[PARAM_DY]
name = _("dY")
type = float
icon = dy.png
tool_tip = _("Y offset")
value = 0.0
header = h1
metric_value = 0.0

[PARAM_DR]
name = _("Rotate")
type = float
digits = 2
icon = angle.png
tool_tip = _("Angle")
value = 0
header = h2
suffix = &#176;

[DEFINITIONS]
content =
;	<eval>self.include_once(file name here)</eval>

[BEFORE]
content =
	(begin #sub_name)
	(group offset and rotation authors : Nick Drobchenko and Fernand Veilleux)
	
	o<#self_id_active> if [#param_act]
		(get and save current coords system offsets)
		#<old_coord_system#ID> = [#<_coord_system> / 10]
		o<get_offsets> CALL
		#<offset_x#ID> = #<_offsets_x>
		#<offset_y#ID> = #<_offsets_y>
		#<offset_z#ID> = #<_offsets_z>
		#<offset_r#ID> = #<_offsets_r>
		
		(calc new offsets)
		#<cx#ID>    = [#<_offsets_x> + #param_cx]
		#<cy#ID>    = [#<_offsets_y> + #param_cy]
		#<angle#ID> = [#<_offsets_r> + #param_dr]
	
		(change coords system)
		G#<_off_rot_coord_system>
		
		(get rotated coordinates then apply to new coords)
		o<rotate_xy> CALL [#<cx#ID> + #param_dx] [#<cy#ID> + #param_dy] [#<cx#ID>] [#<cy#ID>] [#<angle#ID>]
		o<#self_id_change_coords> if [#<_has_z_axis>]
			G10 L2 P#5220 X#<_rotated_x> Y#<_rotated_y> Z#<offset_z#ID> R#<angle#ID>
		o<#self_id_change_coords> else
			G10 L2 P#5220 X#<_rotated_x> Y#<_rotated_y> R#<angle#ID>
		o<#self_id_change_coords> endif
		
		(begin #sub_name items)

[AFTER]
content =
		(end #sub_name items)
		
		(restore coordinate system)
		G#<old_coord_system#ID>
		G10 L2 P#5220 X#<offset_x#ID> Y#<offset_y#ID> Z#<offset_z#ID> R#<offset_r#ID>
		o<#self_id_restore_coords> if [#<_has_z_axis>]
			G10 L2 P#5220 X#<offset_x#ID> Y#<offset_y#ID> Z#<offset_z#ID> R#<offset_r#ID>
		o<#self_id_restore_coords> else
			G10 L2 P#5220 X#<offset_x#ID> Y#<offset_y#ID> R#<offset_r#ID>
		o<#self_id_restore_coords> endif
		
	o<#self_id_active> endif
	(end #sub_name)
